<!doctype html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-4.dtd">

<html>
<head>
<div th:replace="/layout :: head('登录','文档库，当凌科技','当凌文档库是由广州当凌信息科技有限公司开发的一个文档管理系统。')"></div>
<script src="http://parsleyjs.org/dist/parsley.min.js"></script>
</head>
<body>
	<div th:replace="/layout :: header"></div>

	<div class="uk-section">
		<div class="uk-container">
			<div class="uk-card uk-card-default uk-card-body uk-width-1-2@m uk-align-center">
				<h3 class="uk-card-title">登录</h3>
				<form id="login-form" class="uk-form-stacked" th:action="@{/login}" method="post" data-parsley-validate>
					<div class="uk-margin">
						<label class="uk-form-label" for="input-username">账号</label>
						<div class="uk-form-controls">
							<input class="uk-input" id="input-username" required data-parsley-required-message="账号不能为空" type="text"
								name="username" placeholder="请输入账号">
						</div>
					</div>
					<div class="uk-margin">
						<label class="uk-form-label" for="input-password">密码</label>
						<div class="uk-form-controls">
							<input class="uk-input" id="input-password" required data-parsley-required-message="密码不能为空" type="password"
								name="password" placeholder="请输入密码">
						</div>
					</div>
					<div class="uk-margin">
						<button class="uk-button uk-button-primary uk-align-center" type="submit">登录</button>
					</div>
				</form>
			</div>
		</div>
	</div>

	<div th:replace="/layout :: footer"></div>

	<script type="text/javascript" th:inline="javascript">
		var base = /*[[${#httpServletRequest.getContextPath()}]]*/"";
	</script>

	<script type="text/javascript">
		$(function() {
			var $form = $("#login-form");
			$form.parsley().on('field:validated', function() {

			}).on('form:submit', function() {
				$.post($form.attr('action'), $form.serialize(), function(result) {
					if (result.success) {
						location.href = base + "/console";
					} else {
						UIkit.notification(result.msg);
					}
				}, "json");

				return false;
			});
		});
	</script>
</body>
</html>
